import { Module } from '@nestjs/common';
import { AuthorizationService } from './authorization.service';
import { AuthorizationController } from './authorization.controller';
import { Manager } from '../admin/manager/entities/manager.entity';
import { TypeOrmModule } from '@nestjs/typeorm';
import jwtConfig from 'src/config/jwt.config';
import { JwtModule } from '@nestjs/jwt';
import { ConfigModule } from '@nestjs/config';
import { HashingService } from './hashingService';
import { AccessTokenGuard } from './guards/access-token.guard';
import { APP_GUARD } from '@nestjs/core';
import { AuthorizationServiceUser } from './authorization.serviceUser';
import { User } from '../admin/user/entities/user.entity';
import { AuthorizationControllerUser } from './authorization.controllerUser';

@Module({
  imports: [
    TypeOrmModule.forFeature([Manager, User]),
    ConfigModule.forFeature(jwtConfig),
    JwtModule.registerAsync(jwtConfig.asProvider()), // 用于 jwt 认证的签发
  ],
  controllers: [AuthorizationController, AuthorizationControllerUser],
  providers: [
    {
      provide: APP_GUARD,
      useClass: AccessTokenGuard,
    },
    AuthorizationService,
    AuthorizationServiceUser,
    HashingService,
  ],
})
export class AuthorizationModule {}
